package controller

import (
	"gin/response"
	"gin/service"
	"gin/types"
	"github.com/gin-gonic/gin"
)

var (
	NeedManageService service.NeedProject
)

type NeedManage struct {
}

// AssetTotalList 资产统计列表
func (N *NeedManage) AssetTotalList(ctx *gin.Context) {

	var req types.AssetTotalListReq
	err := ctx.ShouldBindJSON(&req)

	if err != nil {
		response.Fail(ctx, nil, err.Error())
		return
	}

	tenantId := service.GetInt64FromContext(ctx, "tenant_id")
	userId := service.GetInt64FromContext(ctx, "user_id")
	resData, queryErr := NeedManageService.AssetTotalList(tenantId, userId, req)
	if queryErr != nil {
		// 查询失败
		response.Fail(ctx, nil, queryErr.Error())
	} else {
		// 查询成功
		response.Success(ctx, gin.H{"data": resData}, "success")
	}
}

// ShotTotalList 镜头统计列表
func (N *NeedManage) ShotTotalList(ctx *gin.Context) {

	var req types.ShotTotalReq
	err := ctx.ShouldBindJSON(&req)

	if err != nil {
		response.Fail(ctx, nil, err.Error())
		return
	}

	tenantId := service.GetInt64FromContext(ctx, "tenant_id")
	//userId := service.GetInt64FromContext(ctx, "user_id")
	resData, queryErr := NeedManageService.ShotTotalList(tenantId, req)
	if queryErr != nil {
		// 查询失败
		response.Fail(ctx, nil, queryErr.Error())
	} else {
		// 查询成功
		response.Success(ctx, gin.H{"data": resData}, "success")
	}
}
